<?php
class Mail_auto extends Admin_Controller {

    function Mail_auto() {
        parent::Admin_Controller();
        $this->load->model('Mail_auto_m');
        $this->_data['listsidebar'] = 'admin/modules/contenu';
        $this->_data['erreur'] = '';
    }

    function index() {
        is_admin();
        $this->detail(1);
    }
    function detail($id=1){
        is_admin();
                     $config = array(
            array('field' => 'titre',
                'rules' => 'required'
            ),
            array('field' => 'contenu',
                'rules' => 'required'
            )
        );
                 $this->form_validation->set_rules($config);
         if($this->input->post('submit')){
                if($this->form_validation->run()){
                  $titre=$this->input->post('titre');
                $contenu=$this->input->post('contenu');

                 $data = array(
                        'titre' => $titre,
                        'contenu' => $contenu
                       );
          $query=$this->Mail_auto_m->update_mail($id,$data);
          $this->_data['annonce'] = "Article a été modifié !";
                }
         }
        $this->_data['page_title'] = "Email automatique";
        $query=$this->Mail_auto_m->get_mail($id);
        $this->_data['query'] = $query;
        $this->admin_view('admin/mail_auto/mail_auto');

    }
}
    ?>